/*******************************************************
* Copyright (c) 2018-2088, By XuXiang all rights reserved.
*
* FileName: NetMsgMatch.h
* Summary: 匹配模块协议。
*
* Author: AutoBuild
* Date: --/--
*******************************************************/

#ifndef __NetMsgMatch_h__
#define __NetMsgMatch_h__

#include "../Macro.h"
#include "../Net/NetMessage.h"
#include "../Util/DataUtil.h"
#include <string>
#include <vector>
using namespace std;

namespace Competition
{
	namespace Net
	{
		//协议号
		namespace MsgID
		{
			const Int32 CS_PLAYER_NUMBER = 2001;				//玩家数量请求
			const Int32 CS_MATCH_BEGIN = 2002;					//开始匹配请求
			const Int32 CS_MATCH_CANCEL = 2004;					//取消匹配请求
			const Int32 CS_MATCH_CONFIRM = 2005;				//确认匹配请求
			const Int32 SC_PLAYER_NUMBER = 2401;				//玩家数量通知
			const Int32 SC_MATCH_BEGIN = 2402;					//匹配开始回复
			const Int32 SC_MATCH_SUCCESS = 2403;				//匹配成功通知
			const Int32 SC_MATCH_STATE = 2404;					//匹配状态通知
			const Int32 SC_MATCH_RESULT = 2405;					//匹配结果通知
		}

		//2001:玩家数量请求
		class CSPlayerNumberRequest : public NetMessage
		{
		};

		//2002:开始匹配请求
		class CSMatchBeginRequest : public NetMessage
		{
		};

		//2004:取消匹配请求
		class CSMatchCancelRequest : public NetMessage
		{
		};

		//2005:确认匹配请求
		class CSMatchConfirmRequest : public NetMessage
		{
		public:
			CSMatchConfirmRequest();
			virtual int Unpack(Byte *buffer, int index);

			Byte State;								//匹配状态(0:未准备 1:已准备)
		};

		//2401:玩家数量通知
		class SCPlayerNumberResponse : public NetMessage
		{
		public:
			SCPlayerNumberResponse();
			virtual int Pack(Byte *buffer, int index);

			Int32 LobbyNumber;						//大厅玩家数量
			Int32 FightNumber;						//战斗玩家数量
		};

		//2402:匹配开始回复
		class SCMatchBeginResponse : public NetMessage
		{
		public:
			SCMatchBeginResponse();
			virtual int Pack(Byte *buffer, int index);

			Byte Result;							//开始结果(0:成功 1:有战斗未结束 2:禁止匹配)
		};

		//匹配玩家信息
		class MatchPlayerInfo : public NetMessage
		{
		public:
			MatchPlayerInfo();
			virtual int Pack(Byte *buffer, int index);

			Int32 UserID;							//用户ID
			string NickName;						//昵称
		};

		//2403:匹配成功通知
		class SCMatchSuccessNotify : public NetMessage
		{
		public:
			SCMatchSuccessNotify();
			virtual int Pack(Byte *buffer, int index);

			Int32 PlayerCount;						//玩家数量
			vector<MatchPlayerInfo> PlayerList;		//玩家列表
			Int64 StartTime;						//确认开始时间
			Int32 WaitTime;							//确认等待时间
		};

		//2404:匹配状态通知
		class SCMatchStateNotify : public NetMessage
		{
		public:
			SCMatchStateNotify();
			virtual int Pack(Byte *buffer, int index);

			Int32 UserID;							//用户ID
			Byte State;								//匹配状态(0:未准备 1:已准备)
		};

		//2405:匹配结果通知
		class SCMatchResultNotify : public NetMessage
		{
		public:
			SCMatchResultNotify();
			virtual int Pack(Byte *buffer, int index);

			Byte Result;							//匹配结果(0:成功 1:自己取消 2:其他人取消 3:未确认)
		};
	}
}

#endif
